<template>
  <div class="main">
    <h2>{{msg}},学校名称是：{{schoolName}},学生姓名是：{{studentName}}</h2>
    <School @sName="getSchoolName"></School>
    <Student ref="student" @click.native="show"></Student>
  </div>
</template>

<script>
import School from "@/components/School"
import Student from "@/components/Student"
export default {
  name: "App",
  components: {School,Student},
  data(){
    return{
      msg:"欢迎光临~",
      schoolName:"",
      studentName:"",
    }
  },
  methods:{
    getSchoolName(name){
      console.log("App收到了，",name)
      this.schoolName=name
    },
    getStudentName(name,...params) {
      console.log("App接收到了，",name,params)
      this.studentName=name
    },
    // getStudentSex(sex){
    //   console.log("App收到了学生姓名，性别，",sex)
    // }
    show(){
      alert("hello~")
    }
  },
  mounted() {
    // this.$refs.student.$on("tName",this.getStudentName)
    // this.$refs.student.$on("tName",function(name){
    //   console.log("App收到了学生性别：",name)
    //   console.log("this",this)
    //   this.studentName=name
    // })
    this.$refs.student.$on("tName",(name)=>{
      console.log("App收到了学生性别：",name)
      console.log("this",this)
      this.studentName=name
    })
  }
}
</script>

<style scoped>
.main{
  background-color: grey;
  padding: 5px;
}
</style>
